package com.feng.zhihao.apigeteway.controller.interfaces;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.feng.zhihao.apigeteway.controller.BaseController;
import com.feng.zhihao.apigeteway.dao.interfaces.InterfaceInfoDao;
import com.feng.zhihao.apigeteway.entity.InterfaceInfo;
import com.feng.zhihao.apigeteway.entity.ModularInfo;
import com.xiaoleilu.hutool.log.LogFactory;

@Controller
@RequestMapping("/interface")
public class InterfaceInfoController extends BaseController{
	com.xiaoleilu.hutool.log.Log logger = LogFactory.get();
	
	@Autowired
	InterfaceInfoDao interfaceInfoDao;
	
	@RequestMapping("getModularInterface.do")
	public String getModularInterface(@RequestParam("modularId")String modularId,Model model){
		InterfaceInfo interfaceInfo=new InterfaceInfo();
		interfaceInfo.setModularInfo(new ModularInfo(modularId));
		List<InterfaceInfo> interfaceInfoItem = interfaceInfoDao.findAll(Example.of(interfaceInfo));
		model.addAttribute("interfaceInfoItem", interfaceInfoItem);
		return "interface/modularInterfaceList";
	}
	
	@RequestMapping("interfaceInfo.do")
	public String getInterfaceInfo(@RequestParam("interfaceId")String interfaceId,Model model){
		InterfaceInfo interfaceInfo = interfaceInfoDao.getOne(interfaceId);
		model.addAttribute("interfaceInfo", interfaceInfo);
		return "interface/interfaceInfo";
	}
	 

}
